import { RouteRecordRaw } from 'vue-router';
import { Layout, StudentLayout } from '@/router/constant';
import { UnorderedListOutlined } from '@vicons/antd';
import { renderIcon } from '@/utils/index';

const routeName = 'student';

/**
 * @param name 路由名称, 必须设置,且不能重名
 * @param meta 路由元信息（路由附带扩展信息）
 * @param redirect 重定向地址, 访问这个路由时,自定进行重定向
 * @param meta.disabled 禁用整个菜单
 * @param meta.title 菜单名称
 * @param meta.icon 菜单图标
 * @param meta.keepAlive 缓存该路由
 * @param meta.sort 排序越小越排前
 *
 * */
const routes: Array<RouteRecordRaw> = [
  {
    path: '/student',
    name: routeName,
    component: Layout,
    redirect: '/student/course',
    meta: {
      title: '我的课程',
      sort: 5,
      permissions: ['student'],
      hidden:true
    },
    children: [
      {
        path: 'student_course_count/:courseID',
        name: 'student_course_count',
        meta: {
          title: '课程统计',
        },
        component: () => import('@/views/student/courseCount.vue'),
      },
      {
        path: 'course',
        name: 'student_course',
        meta: {
          title: '课程列表',
        },
        component: () => import('@/views/student/courseList.vue'),
      },
      {
        path: 'course_detail/:courseID',
        name: 'student_course_detail',
        redirect: to => { return '/student/course_detail/' + to.params.courseID + '/chapter' },
        meta: {
          title: '课程详情',
          hidden: true,
          keepAlive: true,
        },
        component: StudentLayout,
        children: [
          {
            path: 'chapter',
            name: 'student_chapter',
            meta: {
              title: '章节列表',
            },
            component: () => import('@/views/student/chapter/chapter.vue'),
          },
          {
            path: 'discuss',
            name: 'student_discuss',
            meta: {
              title: '讨论列表',
            },
            component: () => import('@/views/student/discuss/discuss.vue'),
          },
          {
            path: 'discussDetail/:discussID',
            name: 'student_discuss_detail',
            meta: {
              title: '讨论室',
            },
            component: () => import('@/views/student/discuss/discussDetail.vue'),
          },
          {
            path: 'exam',
            name: 'student_exam',
            meta: {
              title: '测验列表',
            },
            component: () => import('@/views/student/exam/exam.vue'),
          },{
            path: 'exam_detail/:EID',
            name: 'student_exam_detail',
            meta: {
              title: '测验详情',
            },
            component: () => import('@/views/student/exam/examDetail.vue'),
          },{
            path: 'exam_answer/:EID',
            name: 'student_exam_answer',
            meta: {
              title: '测验统计',
            },
            component: () => import('@/views/student/exam/answer.vue'),
          },
          
        ]
      },
    ],
  },
  {
    path: '/studentTele',
    name: 'studentTele',
    component: Layout,
    redirect: '/student/course',
    meta: {
      title: '课程列表',
      icon: renderIcon(UnorderedListOutlined),
      sort: 5,
      permissions: ['student'],
    },
  }
];

export default routes;
